package com.kate.mall.order.price.coupon;

import com.kate.mall.order.dto.CouponDTO;
import com.kate.mall.order.dto.OrderDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @Description: 现金券抵扣金额计算组件
 * @Auther: 新梦想*陈超
 * @Date: 2021/10/30 19:35
 */
@Component
@Slf4j
public class CashCouponCalculator implements CouponCalculator {
	

	public BigDecimal calculate(OrderDTO order, CouponDTO coupon) throws Exception {
		BigDecimal payableAmount = order.getOrderPrice();
		BigDecimal discountAmount = coupon.getDiscount();

		log.info("======现金券抵扣金额计算组件，订单价格：{},优惠券:{}",payableAmount,discountAmount);
		//if(payableAmount.compareTo(discountAmount)==1) {
		//	return payableAmount;
		//}
		return discountAmount;
	}

}